function exportCsv(datagridId) {
	var datagrid = $('#' + datagridId);
	if(!datagrid){
		console.log('表格不存在');
		return;
	}
	var options = datagrid.datagrid('options');
	if (!options) {
		console.log('获取配置信息失败');
		return;
	}
	var data = datagrid.datagrid('getData');
	var columns = options.columns;

	var queryParams = options.queryParams;
	queryParams.pageSize = data.total;

	var target = '';
	if (columns[0]) {
		for (var i = 0; i < columns[0].length; i++) {
			target += columns[0][i].title + ",";
		}
	}
	if (target.endWith(',')) {
		target = target.substring(0, target.length - 1);
	}
	target += '\n';
	var formValues = $(options.toolbar).find('form').serialize();
	formValues = formValues.replace(/\+/g, " "); // g表示对整个字符串中符合条件的都进行替换  
	var url = options.url;

	var param = JSON.parse(decodeURIComponent(JSON.stringify(conveterParamsToJson(formValues))));
	for ( var v in param) {
		queryParams[v] = param[v];
	}

	$.ajax({
		"type" : "post",
		"dataType" : "json",
		"data" : queryParams,
		"contentType" : "application/x-www-form-urlencoded; charset=UTF-8",
		"url" : url,
		"success" : function(result) {
			for (var i = 0; i < result.rows.length; i++) {
				for (var j = 0; j < columns[0].length; j++) {
					var column = columns[0][j];
					var value = result.rows[i][column.field];
					if (column.formatter) {
						value = column.formatter(value, result.rows[i], j);
					}
					value = delHtmlTag(value);
					target += value + ",";
				}
				if (target.endWith(',')) {
					target = target.substring(0, target.length - 1);
				}
				target += '\n';
			}

			target = "\ufeff" + target;
			var blob = new Blob([ target ], {
				type : 'text/csv'
			}); 
			downFile(blob, new Date().Format('yyyyMMddhhmmss') + ".csv");

		}
	});
}

function downFile(blob, fileName) {
	if (window.navigator.msSaveOrOpenBlob) {
		navigator.msSaveBlob(blob, fileName);
	} else {
		var link = document.createElement('a');
		link.href = window.URL.createObjectURL(blob);
		link.download = fileName;
		link.click();
		window.URL.revokeObjectURL(link.href);
	}
}

String.prototype.startWith = function(str) {
	var reg = new RegExp("^" + str);
	return reg.test(this);
}

String.prototype.endWith = function(str) {
	var reg = new RegExp(str + "$");
	return reg.test(this);
}

function delHtmlTag(str) {
	return str.replace(/<[^>]+>/g, "");//去掉所有的html标记  
}